import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    name: "张三",
    ages: [30, 20, 60, 80]
  },
  getters: {
    filterAge: state => state.ages.filter(m => m < 60)
  },
  //同步
  mutations: {
    changeName(state) {
      debugger;
      state.name = "王五";
    }
  },
  //异步
  actions: {
    changeName(context) {
      debugger;
      context.commit('changeName')
    }
  },
  modules: {
    
  }
})
